import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2025-01-10
 * Time: 10:46
 */
class Solution9 {
    public boolean isIsomorphic(String s, String t) {
        if(s.equals(t)) return true;
        int ret = 0;
        for(int i = 0 ; i < s.length() ; i++){
            ret += s.charAt(i) - t.charAt(i);
        }
        if(ret == 0) return false;
        //1:弄两个hash数组
        int[] nums1 = new int[256];
        int[] nums2 = new int[256];
        for(int i = 0 ; i < s.length() ; i++){
            char ch = s.charAt(i);
            nums1[ch - 'a']++;
        }
        for(int i = 0 ; i < t.length() ; i++){
            char ch = t.charAt(i);
            nums2[ch - 'a']++;
        }
        Arrays.sort(nums1);
        Arrays.sort(nums2);
        for(int j = 0 ; j < nums1.length ;){
            if(nums1[j] == nums2[j]){
                j++;
            }else{
                return false;
            }
        }
        return true;
        //排个序
        //再遍历是否相等
    }
}
public class Test9 {
    public static void main(String[] args) {
        Solution9 solution9 = new Solution9();
        String s =  "papap";
        String t =  "titii";
        solution9.isIsomorphic(s,t);
    }
}
